<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ include file="../include/base.jsp" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
	<title>CRM客户关系管理系统——任务管理</title>
	<link rel="stylesheet" type="text/css" href="http://lib.sinaapp.com/js/bootstrap/2.0.3/css/bootstrap.min.css" />
	<link href="<%=basePath %>css/all.css" media="screen" rel="stylesheet" type="text/css" />
	<link href="<%=basePath %>css/application.css" media="print" rel="stylesheet" type="text/css" />
	<link href="<%=basePath %>css/blue.css" media="screen" rel="stylesheet" title="Theme" type="text/css" />
 
	<script type="text/javascript" src="http://lib.sinaapp.com/js/jquery/1.7.2/jquery.min.js"></script>
	<script type="text/javascript" src="http://lib.sinaapp.com/js/bootstrap/2.0.3/js/bootstrap.min.js"></script>
	
	<script src="<%=basePath %>js/ga.js" async="" type="text/javascript"></script>
	<script src="<%=basePath %>js/application-114d9a8373cd197d7265335db95e1a0a.js" type="text/javascript"></script>
	
	
   
   
   
</head>

<body class="clearfix overview narrow_page_with_sidebar_outside webkit  windows"  onloadnot="setupZoom()">
  <div id="quick_show_window" style="display: none">
    <div class="quick_show_window_position">
      <div class="quick_show_window_wrapper">
        <div class="quick_show_window_content">
        </div>
      </div>
    </div>
  </div>

  <div id="task_flash" style="display: none">
    <div class="inner_task_flash">
    </div>
  </div>



	<div id="app_header">
	<div class="background"></div>
	<div class="boundary">
		<div id="upgrade_bar"></div>
		<div id="inner_header_wrapper">
			<a href="/" id="app_logo">
			<img alt="Logo-topleft" src="img/logo-topleft.png" style="padding-top: 8px;" />
			</a>
			<table id="page_actions">
				<tr>
					<td class="tiny">
						<div class="menu_container">
								<span class="action">
									<a href="/people/new" behavior="return_to">
										<span>添加联系</span>
									</a>
								</span>
						</div>
					
					</td>
					<td class="tiny">		
						<div class="menu_container">
							<span class="action">
								<a href="#taskModal" class="btn btn-primary" data-toggle="modal" >
									<span>新的任务</span>
								</a>
								
								
								
								
							</span>
						</div>
					</td>
					<td class="long">
						<div id="search_wrapper">
							<div class="quick_find">
								<div class="field" style="position:relative;">
									<input type="text" id="sidebar_live_search" name="term" title="a contact, case, deal, or tag..."/>
								</div>
							</div>
						</div>
					</td>
				</tr>
			</table>

			

			
			
			
			
			
			
			<div id="global_links_container">
				<div class="menu_container">
			      <a href="#" class="name menu_target">
			        设置
			        <span>▼</span>
			      </a>
			      <div id="balloon_global_links" class="balloon center menu_content ">
						<div class="balloon_pointer">
							<div class="balloon_arrow menu_target"></div>
							<div class="balloon_arrow_border"></div>
						</div>
						<div class="balloon_wrapper">
							<div class="balloon_content">
								<ul class="global_links">
								<li><a href="#" class="">用户</a></li>
								<li><a href="#" class="">密码重置</a></li>
								<li><a href="#" class="">分组</a></li>
								</ul>
							</div>
						</div>
					</div>
				</div>
           </div>
		</div>
	</div>
</div>


	<div id="wrapper">
	<div id="inner_wrapper">
		<div id="main_body" class="column">
			<div id="blank_slate" class="clearfix"></div>
			
		
		<div id="screen_body">
		  
			<!--// page sidebar -->

			<!-- page -->
			<div id="page">

				<!-- page header -->
				
				<div id="page_header_wrapper">
				  
				   
					<div id="page_header">
						 
						<div class="page_header">
						<h1>添加机会</h1>
						
						</div>

					</div>
					
				</div>
				
				<!--// page header -->

				<!-- page contents -->
				<div id="page_contents_wrapper" class="clearfix">

				  <!-- main column -->
				  <div id="page_main_column" class="column">
					<div class="liner">
					   <!-- 自己写的主要代码区 -->
						<div>
						<form accept-charset="UTF-8" action="/chances" class="simple_form form-vertical" id="chance_form" method="post" novalidate="novalidate"><div style="margin:0;padding:0;display:inline"><input name="utf8" value="✓" type="hidden"><input name="authenticity_token" value="hT63IkZWfLvwswV0Z56JTQfUWMJlkb9RL9NBX4fGHy8=" type="hidden"></div>
										<div class="control-group string optional marco_polo_container">
											<label class="string optional control-label" for="chance_contact">联系人</label>
											
											<div class="controls">
												<input autocomplete="off" class="input-xlarge mp_input" id="contact.name" name="contact.name" type="text">
												<ul style="display: none;" class="typeahead dropdown-menu mp_list"></ul>
												<input id="chance_contact_id" name="chance[contact_id]" type="hidden">
												<p class="help-block">输入联系人姓名或公司名称（并从下拉提示列表中选取一个）</p>
											</div>
							
										</div>
										<div class="control-group string required"><label class="string required control-label" for="chance_name"><abbr title="required">*</abbr> 机会名称</label><div class="controls"><input class="string required input-xlarge" id="chance_name" name="chance[name]" size="50" type="text"></div></div>

										<div class="control-group text optional"><label class="text optional control-label" for="chance_description">机会描述或背景信息</label><div class="controls"><textarea style="height: 55px;" class="text optional content" cols="40" id="chance_description" name="chance[description]" rows="20"></textarea></div></div>
										
										<div class="control-group float optional"><label class="float optional control-label" for="chance_price">金额</label><div class="controls"><div class="input-prepend">
											<span class="add-on">元</span>
											
											<input class="numeric float optional price" id="chance_price" name="chance[price]" type="text">
											
											<input id="chance_price_type" name="chance[price_type]" value="fixed" type="hidden">
											
										<!-- 	
											<select id="price_type_pulldown" name="type_pulldown" onchange="Deals.selectBidType(this)"><option value="fixed" selected="selected">固定价</option>
												<option value="hour">每小时</option>
												<option value="month">每月</option>
												<option value="year">每年</option></select>
											<span id="special_bid" style="display:none;">
												共
												<input id="chance_duration" name="chance[duration]" size="30" style="width:50px;" type="text">
											 	<span id="time_unit"></span>
											</span>
											
										-->	
												
											
								</div></div></div>		
										<div class="control-group integer optional"><label class="integer optional control-label" for="chance_category_id">分类</label><div class="controls">
											<select data="ChanceCategory" id="chance_category_id" name="chance[category_id]" onchange="changeCategory(this)"><option selected="selected" value="">无</option>
								<option value="new">新建分类 ...</option></select>
											<a href="https://1344495893.workxp.info/crm_categories?type=chance">编辑分类</a>
								</div></div>		
												<div class="control-group select optional"><label class="select optional control-label" for="chance_assigned_user_id">谁负责？</label><div class="controls"><select class="select optional" id="chance_assigned_user_id" name="chance[assigned_user_id]"><option selected="selected" value="">无</option>
								<option value="6721">我</option></select></div></div>
												
												<div class="control-group string optional"><label class="string optional control-label" for="chance_access_policy">谁可以看见这个机会？</label><div class="controls">
													 <div id="select_access_policy_for_Chance_" class="select_access_policy">
									<div class="radio scope activated">
										<input checked="checked" id="chance_scope_everyone" name="chance[scope]" value="Everyone" type="radio"> 所有同事
									</div>
									<div class="radio scope ">
										<input id="chance_scope_owner" name="chance[scope]" value="Owner" type="radio"> 只有我能看见
										<input id="chance_owner_id" name="chance[owner_id]" value="6721" type="hidden">
									</div>
									
							<c:forEach items = "${groupList}" var = "group">
										<div class="radio scope ">
											<input id="chance_scope_namedgroup" name="chance[scope]" value="NamedGroup" type="radio"> 选择一个组...
											<div class="editor">
											<select class="named_group" id="chance_group_id" name="chance[group_id]">
												<option selected="selected" value="">选择一个组</option>
												<option value="698">${group.name}</option>
											</select> 
											</div>
											<div class="named_groups_data" data="{&quot;698&quot;:[]}"></div>
										</div>
							</c:forEach>
										
									<div class="radio scope  hide">
										<input class="adhoc_group_ids" id="chance_user_ids" name="chance[user_ids]" type="hidden">
										<input id="chance_scope_adhocgroup" name="chance[scope]" value="AdhocGroup" type="radio"> 选择同事...
										<div class="editor">
											<div class="adhoc_group_member template" style="display: none;">
												<select disabled="disabled" id="user_ids_" name="user_ids[]"></select> 
												<span class="sprite remove" style="display:inline-block;background: url(/assets/workxp_sprites.png) no-repeat scroll -189px -181px transparent; width: 14px; padding-top: 14px;" title="" id=""></span>
												<span class="sprite add" style="display:inline-block;background: url(/assets/workxp_sprites.png) no-repeat scroll -189px -197px transparent; width: 14px; padding-top: 14px;" title="" id=""></span>
											</div>
											<div class="adhoc_group_members"></div>
										<select class="new_adhoc_group_member" id="" name=""><option value="" selected="selected">选择一个同事...</option></select> 
										</div>
									</div>
									
								</div>

								<script>
									var container = $('#select_access_policy_for_Chance_');
									$('.scope input[type=radio]', container).live('click', function(event) {
									var activated = $(event.target).parent();
									$('.scope.activated', container).removeClass('activated')
									activated.addClass('activated');
										changePermission()
								  });

									$('.scope select.named_group', container).live('change', function() {
										changePermission()
									})

								  AdhocGroupMember.menu = $('select.new_adhoc_group_member', container)
									AdhocGroupMember.menu.live('change', function() { AdhocGroupMember.insert() });
									
									function changePermission() {
									  container.trigger('permission:change', [viewers()]);
									}
									
									function viewers() {
									  switch ($('.scope.activated input[type=radio]', container).val()) {
									  case 'Owner':
										return [];
									  case 'NamedGroup':
										return namedGroupMembers();
									  case 'AdhocGroup':
										return adhocGroupMembers();
									  default:
										return everyone();
									  }
									}
									
									function adhocGroupMembers() {
										return $('.adhoc_group_members .adhoc_group_member select', container).map(function(index, menu){ return $(menu).val() });
									}
									
									function everyone() {
									  return $('option', AdhocGroupMember.menu).map(function(index, option){
										if ($(option).val()) return $(option).val();
									  });
									}
									
									function namedGroupMembers() {
									  return namedGroups()[$('select.named_group', container).val()] || [];
									}
									
									function namedGroups() {
									  return $.parseJSON($('.named_groups_data', container).attr('data'));
									}
									
									function updateUserIds() {
										var ids = $.makeArray(adhocGroupMembers())
										ids.push('6721')
										ids = ',' +  ids.join(',') + ','
										$('.scope .adhoc_group_ids', container).val(ids)
										changePermission()
									}
									
								  function AdhocGroupMember(member) {
										$('select', member).live('change', updateUserIds);
									$('span.sprite.remove', member).live('click', function(){ AdhocGroupMember.remove(member); });
									$('span.sprite.add'   , member).live('click', function(){ AdhocGroupMember.add(member);    });
									return member;
								  }

									AdhocGroupMember.remove = function(member) {
									var removed = member.remove()
									var members = $('.adhoc_group_members .adhoc_group_member', container)
									if (members.length === 0) {
									  AdhocGroupMember.activateMenu()
									} else {
									  if (removed.hasClass('last')) members.last().addClass('last')
									}
										updateUserIds()
								  }

								  AdhocGroupMember.add = function(lastMember) {
									lastMember.removeClass('last')
									AdhocGroupMember.activateMenu()
								  }

								  AdhocGroupMember.insert = function() {
									if ($.trim($(AdhocGroupMember.menu).val()) != '' && $.inArray($(AdhocGroupMember.menu).val(), adhocGroupMembers()) < 0) {
									  $('.adhoc_group_members .last.adhoc_group_member', container).removeClass('last')
									  $('.adhoc_group_members', container).append(AdhocGroupMember.create().addClass('last'))
									  AdhocGroupMember.deactivateMenu()
											updateUserIds()
									} else {
									  AdhocGroupMember.activateMenu()
									}
								  }

								  AdhocGroupMember.create = function() {
									var member = $('.adhoc_group_member.template', container).clone()
									member.removeClass('template').show()
										$('select', member).removeAttr('disabled').val($(AdhocGroupMember.menu).val())
									return AdhocGroupMember(member)
								  }

								  AdhocGroupMember.activateMenu = function() {
									var ids  = adhocGroupMembers()
									var menu = AdhocGroupMember.menu
									if (ids.length > 0) {
									  menu.children().first().html('添加同事...')
									} else {
									  menu.children().first().html('选择一个同事...')
									}
									$(menu).val("")
									$(menu).removeAttr('disabled').show()
								  }

								  AdhocGroupMember.deactivateMenu = function() {
									$(AdhocGroupMember.menu).attr('disabled', 'disabled').hide()
								  }
									
									
									changePermission()
								</script>


								</div></div>		
										<div class="form-actions">
											<input class="btn btn-primary" name="commit" onclick="$('chance_form').addClassName('progress')" value="添加这个机会" type="submit">
											<a href="https://1344495893.workxp.info/chances" class="btn">取消</a>
										</div>
								</form>
														

														








						</div>
						 <!-- 自己写的主要代码区 -->
					</div>
				  </div>
				  <!--// main column -->

				</div>
				<!--// page contents -->
			  
			</div>
			<!--// page -->
		  </div>
			
			
			
			<div style="margin-top: 30px"> </div>        
		</div>
		
    </div>
    </div>
</div>

  <hr style="display: none;" />
	<div id="preloaded_images" style="position:absolute; height:0px; overflow:hidden;">
		<img alt="Dots-white" src="img/dots-white.gif" />
		<img alt="Dots-black" src="img/dots-black.gif" />
	</div>
 
	
	
	
	
</body>
</html>
	